import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description: WYZ
 * User: DELL
 * Date: 2024-05-09
 * Time: 14:59
 */
public class Main4 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int T = scanner.nextInt();
        while (T-- > 0) {
            long l = scanner.nextInt();
            long r = scanner.nextInt();
            long temp = r - 2 * l + 1;
            if (temp <= 0) {
                System.out.println(0);
                continue;
            }
            temp = temp * (temp + 1);
            temp /= 2;
            System.out.println(temp);
        }
    }
}

